package com.xiaoyuer.weixin.config;

import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * @author lcz
 * @desc wx相关配置
 * @mail lcz_0130@163.com
 * @date 2023/12/28
 */

@Configuration
public class WxConfig {
    @Resource
    private WeChatConfigure weChatConfigure;
    @Bean
    public WxMpService wxMpServiceImpl() {
        WxMpService wxMpService = new WxMpServiceImpl();
        // 配置基本信息
        WxMpDefaultConfigImpl wxMpDefaultConfig = new WxMpDefaultConfigImpl();
        wxMpDefaultConfig.setAppId(weChatConfigure.getAppId());
        wxMpDefaultConfig.setSecret(weChatConfigure.getSecret());
        // 设置基本信息
        wxMpService.setWxMpConfigStorage(wxMpDefaultConfig);
        return wxMpService;
    }
}
